﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Text;
using Ngram;
using Ngram.Utils;

namespace NgramServer
{
    // NOTE: You can use the "Rename" command on the "Refactor" menu to change the class name "Service1" in both code and config file together.
    public class NgramService : INgramService
    {
        PProcess pp = new PProcess();
        public string getResult(string data)
        {
            return pp.process(data, PProcess.NgramModel.TypeIII) + ":" + pp.process(data, PProcess.NgramModel.TypeI) + ":" + pp.process(data, PProcess.NgramModel.TypeII) + ":" + pp.process(data, PProcess.NgramModel.TypeIV);
        }
        public string getWord(string w)
        {
            string wordArr = w;
            w = processUtils.ConvertToUnSign(w);
            if (Data.P_One.ContainsKey(w))
            {
                wordArr = "";
                foreach (KeyValuePair<string, double> pair in Data.P_One[w])
                {
                    wordArr += pair.Key + ":";
                }
                wordArr = wordArr.Remove(wordArr.Length - 1);
            }
            return wordArr;
        }
        
    }
}
